package Week2.J0422;

// 双队列 一个队列存放最终要输出的 另一个队列存放要拿来比较的
// 可以用 StringBuffer ?

// 如果是数字, 加到队列中, count++ -> 当count > counted, 说明此时队列中的数字字串大于之前存储的

import java.util.Scanner;

public class 在字符串中找出连续最长的字符串 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char[] arr = scanner.next().toCharArray();
        StringBuffer sbrRet = new StringBuffer();
        StringBuffer sbrComp = new StringBuffer();
        int count = 0;
        int counted = 0;

        for (int i = 0; i < arr.length; i++) {
            if (Character.isDigit(arr[i])) {
                sbrComp.append(arr[i]);
                count++;
            }
            if ((i > 0 && Character.isDigit(arr[i-1])
                    && !Character.isDigit(arr[i])
                    && count >= counted)
                    || (i == arr.length-1
                    && Character.isDigit(arr[i])
                    && count >= counted)) {
                sbrRet = new StringBuffer(sbrComp);
                sbrComp.delete(0,sbrComp.length());
                counted = count;
                count = 0;
            }
            if (!Character.isDigit(arr[i])) {
                count = 0;
            }
        }

        System.out.println(sbrRet.toString());
    }
}
